Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class RectangleLinearGradientBrush

    Private Sub RectangleLinearGradientBrush_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim cx As Integer = Me.Width
        Dim cy As Integer = Me.Height
        Dim rectBrush As New Rectangle(cx \ 4, cy \ 4, cx \ 2, cy \ 2)

        Dim lgbrush As New LinearGradientBrush(rectBrush, Color.White, Color.Black, LinearGradientMode.ForwardDiagonal)

        e.Graphics.FillRectangle(lgbrush, 0, 0, cx, cy)
        e.Graphics.DrawRectangle(Pens.Black, rectBrush)

    End Sub

    Private Sub RectangleLinearGradientBrush_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class